package com.ogawa.projectcommon.widget

import android.content.Context
import android.graphics.Color
import android.view.View
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.ogawa.projectcommon.R
import com.ogawa.projectcommon.bean.HeatRollBean
import kotlinx.android.synthetic.main.dialog_heat_edit.*

class HeatEditDialog(context: Context) :
    BottomSheetDialog(context, R.style.BottomSheetDialogStyle) {

    init {
        setContentView(R.layout.dialog_heat_edit)
        delegate.findViewById<View>(com.ogawa.base.R.id.design_bottom_sheet)?.setBackgroundColor(
            Color.TRANSPARENT
        )
        tv_no.setOnClickListener { dismiss() }
    }

    fun show(heatRollBean: HeatRollBean? = null) {
        if (heatRollBean != null) {
            tr_view.setTime(heatRollBean.startTime, heatRollBean.endTime)
        }
        show()
    }

    fun isTimeLegal(): Boolean {
        return tr_view.isTimeLegal(true)
    }

    fun setConfirmClickListener(listener: View.OnClickListener) {
        tv_yes.setOnClickListener(listener)
    }

    fun getTimeRangeView(): TimeRangeView {
        return tr_view
    }

    fun getStartTime(): Int {
        return tr_view.getStartTime()
    }

    fun getEndTime(): Int {
        return tr_view.getEndTime()
    }
}